package com.example.camelakkaexamples.cameljmsconsumerroute

import org.apache.camel.Exchange
import akka.actor.Actor._
import akka.actor.{ Actor, ActorRef }
import akka.camel.{Consumer, Producer, Oneway, Message}
import org.springframework.context.support.ClassPathXmlApplicationContext

class JmsConsumer() extends Actor with Consumer {
  def endpointUri = "activemq:queue:FOO.BAR"
  protected def receive = {
    case msg: Message => println(msg.body)
  }
}

class JmsProducer() extends Actor with Producer with Oneway {
  def endpointUri = "activemq:queue:FOO.BAR"
}

object CamelAkkaApp extends Application {
  val appctx = new ClassPathXmlApplicationContext("/applicationContext.xml")

  actorOf(new JmsConsumer).start
  val jmsProducer = actorOf(new JmsProducer).start
  jmsProducer !! "Hello world!"

  appctx.close

  exit
}
